package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.ShoppingCart;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface ShoppingCartMapper {

    /**
     * 查询购物车 是否有重复商品
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart>  find(ShoppingCart shoppingCart);

    /**
     * 数量加一
     * @param shoppingCart
     */
    @Update("update shopping_cart set number=#{number} where id=#{id}")
    void updateNumber(ShoppingCart shoppingCart);

    /**
     * 数据加入 购物车
     * @param shoppingCart
     */
    @Insert("insert into shopping_cart (name, image, user_id, dish_id, setmeal_id, dish_flavor, number, amount, create_time)" +
            "values (#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void insert(ShoppingCart shoppingCart);

    /**
     * 清空购物车
     * @param userid
     */
    @Delete("delete  from  shopping_cart where  user_id=#{userid}")
    void deletes(Long userid);

    /**
     * 根据id删除商品
     * @param id
     */
    @Delete("delete  from shopping_cart where  id=#{id}")
    void deleteById(Long id);
}
